﻿using Microsoft.Reporting.WinForms;
using System;
using System.Data;
using System.Windows.Forms;

namespace KYBM
{
    public partial class FrmSTOReport : Form
    {
        public DataTable Sourse { get; set; }
        
        public FrmSTOReport()
        {
            InitializeComponent();
        }

        private void FrmSTOReport_Load(object sender, EventArgs e)
        {
            tsCmbStyle.SelectedIndex = 0;
            BindData();
        }

        private void BindData()
        {

            reportViewer.ProcessingMode = ProcessingMode.Local;

            LocalReport localReport = reportViewer.LocalReport;

            localReport.ReportPath = "STO.rdlc";

            //添加数据源
            ReportDataSource DataSet1 = new ReportDataSource();
            DataSet1.Name = "DataSet1";
            DataSet1.Value = Sourse;

            localReport.DataSources.Clear();
            localReport.DataSources.Add(DataSet1);



            //添加参数
            localReport.SetParameters(
                new ReportParameter[] { new ReportParameter("Title", "凯扬生产单"),new ReportParameter("Style",tsCmbStyle.SelectedIndex.ToString())});

            // 刷新报表
            reportViewer.RefreshReport();
        }

        private void tsCmbStyle_SelectedIndexChanged(object sender, EventArgs e)
        {
            BindData();
        }
    }
}
